
*************************************************************
**** Table A1: GROWTH IN OUTSOURCED RECRUITING  PANEL B  ****
**** DATA FOR EMPLOYMENT PLACEMENT AGENCIES 			 ****
*************************************************************

*2017
import delimit using ../Data/Raw/Census/ECNBASIC2017.EC1756BASIC_data_with_overlays_2021-01-22T151229.csv, delim(",") clear varnames(1)

keep if inlist(naics2017, "56131")
rename naics2017 naics
destring year firm estab rcptot payann payqtr1 emp , replace
rename naics2017_label naics_label 
keep year naics firm estab rcptot payann payqtr1 emp naics_label
 
tempfile 2017
save "`2017'"
 
 

*2002
import delimit using ../Data/Raw/Census/ECN_2002_US_56A1_with_ann.csv, delim(",") clear varnames(1)
keep if inlist(naicsid, "56131")
rename naicsid naics
rename yearid year 
rename payant payann
rename payq1t payqtr1

destring year estab rcptot payann payqtr1 emp , replace
keep year naics estab rcptot payann payqtr1 emp 

tempfile 2002
save "`2002'"



use  "`2002'", clear
append using "`2017'" 



*rescale to 2002
foreach y in 2002 { 
	foreach x in estab rcptot payann payqtr1 emp {
		qui sum `x' if year==`y'
		qui gen `x'_`y' =`x'/r(mean)*100
	}
}



 sum estab_2002 rcptot_2002 payann_2002 emp_2002 if year==2017



 

*************************************************************
**** Table A1: GROWTH IN OUTSOURCED RECRUITING  PANEL B  ****
**** DATA FOR US ECONOMY				     			 ****
*************************************************************

*2017:
import delimit using "../Data/Raw/Census/ECNBASIC2017.EC1700BASIC_data_with_overlays_2021-01-23T075512.csv", delim(",") clear varnames(1)

keep if typop_label=="All establishments"
keep if taxstat_label=="All establishments"

// same categories as 2002
drop if inlist(naics2017,"21", "23", "31-33","44-45","48-49(106)")


destring year firm estab rcptot payann payqtr1 emp , replace
collapse (sum) emp est rcptot payann
gen year = 2017

tempfile year2017
save "`year2017'"


* 2002:
import delimit using "../Data/Raw/Census/ECN_2002_US_00A1_with_ann.csv", delim(",") clear varnames(1)


keep if strlen(naicsid) ==2
drop if inlist(optaxid,"10","20")
drop if inlist(optaxid,"N","T")


destring year estab rcptot payant  emp , replace
collapse (sum) emp est rcptot payant


gen year = 2002

tempfile year2002
save "`year2002'"

append using "`year2017'"


gen pay = payant
replace pay = payann if year==2017

* rescale to 2002
foreach y in 2002 { 
	foreach x in  emp estab rcptot pay {
		* Scale to 2002
		qui sum `x' if year==`y'
		qui gen `x'_`y' =`x'/r(mean)*100
	}
}

sum emp_2002 estab_2002 rcptot_2002 pay_2002 if year==2017

